using System.Windows.Forms;
using Nuwanda.TfsSpotlight.Shell.Proxies.Interfaces;

namespace Nuwanda.TfsSpotlight.Shell.Proxies
{
    public class MenuStripProxy : IMenuStrip
    {
        private readonly MenuStrip _menuStrip;
        private readonly ControlInvoker _menuInvoker;

        public MenuStripProxy(MenuStrip menuStrip)
        {
            this._menuStrip = menuStrip;
            this._menuInvoker = new ControlInvoker(menuStrip);
        }

        public void Clear()
        {
            this._menuInvoker.RunInControlsThread(() => this._menuStrip.Items.Clear());
        }

        public bool Visible
        {
            get { return this._menuInvoker.RunAndReturnInControlsThread(() => this._menuStrip.Visible); }
            set { this._menuInvoker.RunInControlsThread(() => this._menuStrip.Visible = value); }
        }
    }
}